Unit 1 · Lesson 6

Representing Text

FRQ · Warm-Up

What Does This List Represent?

On your own, look at the list of number pairs below.

11
214
74
1031

What do you think this list represents? Once you have an idea, come up with another item that belongs on the list, and be ready to explain why.

🧑‍🤝‍🧑 Activity · Get Ready

Head to Your Tables

For this activity, get into pairs. You'll need a way to send short messages back and forth without talking.

Activity · Design Challenge

Sending Messages

Look at the samples below. Using only numbers, you will need to communicate messages like these to your partner. No letters or other characters allowed, just numbers!

Together, come up with a system that will let you do this.

hey
ttyl
morning
Design Challenge · Share Out

Share Your System

Before we start sending real messages, each pair briefly explain the system you came up with. What does each number mean?

Challenge 1

Send the Message

Partner A

Come up front to find out the message you'll need to send. Using your system, send it to your partner.

Partner B

Figure out what the message says. You'll need to tell me what it said.

🤐 No talking!
Challenge 1 · Share Out

How Did You Send It?

Each pair, explain your system: how did you turn the message into numbers, and how did your partner turn the numbers back into words?

Challenge 1 · Answer

Check Your Answer

Tsk tsk

Make sure your message matches this exactly, including capitalization and spacing.

Take a minute with your partner to update your system if you need to.

Challenge 2

Send the Message

Partner A

Figure out what the message says. You'll need to tell me what it said.

Partner B

Come up front to find out the message you'll need to send. Using your system, send it to your partner.

🤐 No talking!
Challenge 2 · Share Out

How Did You Send It?

Each pair, explain your system: how did you turn the message into numbers, and how did your partner turn the numbers back into words?

Challenge 2 · Answer

Check Your Answer

great!

Make sure your message matches this exactly, including the punctuation.

Take a minute with your partner to update your system if you need to.

Challenge 3

Send the Message

Partner A

Come up front to find out the message you'll need to send. Using your system, send it to your partner.

Partner B

Figure out what the message says. You'll need to tell me what it said.

🤐 No talking!
Challenge 3 · Share Out

How Did You Send It?

Each pair, explain your system: how did you turn the message into numbers, and how did your partner turn the numbers back into words?

Challenge 3 · Answer

Check Your Answer

Free at 5?

Make sure your message matches this exactly, including capitalization, punctuation, and spacing.

Take a minute with your partner to update your system if you need to.

Challenge 4

Send the Message

Partner A

Figure out what the message says. You'll need to tell me what it said.

Partner B

Check the chat for the message you need to send. Using your system, send it to your partner.

🤐 No talking!
Challenge 4 · Share Out

How Did You Send It?

Each pair, explain your system: how did you turn the message into numbers, and how did your partner turn the numbers back into words?

Challenge 4 · Answer

Check Your Answer

Cya 2nite!

Make sure your message matches this exactly, including capitalization, punctuation, and spacing.

Nice work. You just built your own system for representing text with numbers.

Class Discussion

What Was Your System?

How many bits would you need to send one character in your message? How do you know?

Hint: What is the largest number your system uses? How many bits would it take to represent that number?

Let's call the number of bits it takes to send one character a byte. How many bytes would it take to send a message like this one?

running late, omw
How Computers Represent Text

Every Character Gets a Number

Computers assign a number to every letter, digit, and symbol on a keyboard, plus a handful of control characters that don't print anything at all. Control characters are instructions like move over one space or move to the next line.

0NUL
9TAB
10LF · new line
13CR · return
27ESC
127DEL

Every time you press Tab or Enter, you're sending one of these numbers.

This numbering system is called ASCII (pronounced "ask-ee").

Reference

The Printable ASCII Characters

digits
uppercase
lowercase
punctuation
control
32SP
33!
34"
35#
36$
37%
38&
39'
40(
41)
42*
43+
44,
45-
46.
47/
480
491
502
513
524
535
546
557
568
579
58:
59;
60<
61=
62>
63?
64@
65A
66B
67C
68D
69E
70F
71G
72H
73I
74J
75K
76L
77M
78N
79O
80P
81Q
82R
83S
84T
85U
86V
87W
88X
89Y
90Z
91[
92\
93]
94^
95_
96`
97a
98b
99c
100d
101e
102f
103g
104h
105i
106j
107k
108l
109m
110n
111o
112p
113q
114r
115s
116t
117u
118v
119w
120x
121y
122z
123{
124|
125}
126~
127DEL
Wrap Up

From Words to Numbers to Bits

Wrap Up · Layers

Every Message Is Just Numbers

Take an ordinary text message.

Text
h
o
w
'
s
 
i
t
 
g
o
i
n
g
?
ASCII
104
111
119
39
115
32
105
116
32
103
111
105
110
103
63
Binary
01101000
01101111
01110111
00100111
01110011
00100000
01101001
01110100
00100000
01100111
01101111
01101001
01101110
01100111
00111111

We don't have to think about these layers when we send a text message, but every message is really just zeros and ones underneath.

The Real Challenge

Where Does One Number End?

Recall: how did you make sure your partner knew where one number ended and the next began?

On your whiteboards, you had gaps between your numbers. A computer's bit stream doesn't. It's just one long line of 0s and 1s with no spaces at all.

011010000110111101110111001001110111001100100000011010010111010000100000011001110110111101101001011011100110011100111111

So how does the computer know where h ends and o begins?

01101000 01101111 01110111 00100111 01110011 00100000 01101001 01110100 00100000 01100111 01101111 01101001 01101110 01100111 00111111

Everyone agrees ahead of time: every character is exactly 8 bits, one byte. Count off eight bits, and you've found the next character, no gaps required.

Wrap Up

Finish It Off

Answer the reflection question on code.org. Use this link to get there.